home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / quickplot / part2 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  54.1 KB

  1. Subject: lplot and quickplot (Part 2 of 2)
  2. From: Duane Hesser <talcott!seismo!hplsla!tikal!sysad>
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 94
  7. Submitted by: Duane Hesser <seismo!hplsla!tikal!sysad>
  8.  
  9. #! /bin/sh
  10. # This is a shell archive, meaning:
  11. # 1. Remove everything above the #! /bin/sh line.
  12. # 2. Save the resulting text in a file.
  13. # 3. Execute the file with /bin/sh (not csh) to create the files:
  14. #    Makefile
  15. #    Makefile.lplot
  16. #    Makefile.quick
  17. #    alpha_plot.c
  18. #    functions.c
  19. #    global.c
  20. #    iobuf.c
  21. #    lplot.c
  22. #    read_stream.c
  23. #    defs.h
  24. #    extern.h
  25. #    io.h
  26. #    testprogs.d
  27. # This archive created: Fri May  2 18:21:02 1986
  28. export PATH; PATH=/bin:$PATH
  29. echo shar: extracting "'Makefile'" '(1452 characters)'
  30. if test -f 'Makefile'
  31. then
  32.     echo shar: will not over-write existing file "'Makefile'"
  33. else
  34. cat << \SHAR_EOF > 'Makefile'
  35. # $Header: Makefile,v $
  36. # $Log: Makefile,v $
  37.  
  38. BIN=/usr/public/bin
  39. MAN=/usr/man/manp
  40.  
  41. nothing:
  42.     @echo 'Use:'
  43.     @echo 'make all             to update lplot and quickplot'
  44.     @echo 'make new             to make both from scratch'
  45.     @echo 'make clean           to remove .o files'
  46.     @echo 'make bclean          to remove binaries and .o files'
  47.     @echo 'make lplot           to make only lplot'
  48.     @echo 'make quickplot       to make only quickplot'
  49.     @echo 'make install         to update and install both'
  50.     @echo 'make install_l       to update and install lplot'
  51.     @echo 'make install_q       to update and install quickplot'
  52.     @echo 'make install.man     to update and install man pages'
  53.  
  54. all:    lplot quickplot 
  55.  
  56. new:    bclean all
  57.  
  58. lplot: MAKINGLPLOT    FORCE
  59.     make -f Makefile.lplot
  60.  
  61. quickplot: MAKINGQUICK    FORCE
  62.     make -f Makefile.quick
  63.  
  64. FORCE:
  65.  
  66. bclean:
  67.     -rm -f *.o quickplot lplot LQPLOT.*
  68.  
  69. clean:
  70.     -rm -f *.o  LQPLOT.*
  71.  
  72. copy:
  73.     cpr -n -s defs.h global.c extern.h io.h lplot.c read_stream.c \
  74.     functions.c iobuf.c  alpha_plot.c | lprn -E4
  75.  
  76. install: install_l install_q
  77.  
  78. install_l: lplot 
  79.     -rm -f $(BIN)/lplot $(BIN)/rlplot $(BIN)/quickplot
  80.     install -s lplot $(BIN)
  81.     ln $(BIN)/lplot $(BIN)/rlplot
  82.  
  83. install_q: quickplot
  84.     install -s quickplot $(BIN)
  85.  
  86. install.man:
  87.     cp lplot.p quickplot.p $(MAN)
  88.     man lplot > /dev/null
  89.     man quickplot > /dev/null
  90.  
  91. MAKINGLPLOT:
  92.     -rm -f MAKINGQUICK *.o
  93.     touch MAKINGLPLOT
  94.  
  95. MAKINGQUICK:
  96.     -rm -f MAKINGLPLOT *.o
  97.     touch MAKINGQUICK
  98.  
  99. SHAR_EOF
  100. if test 1452 -ne "`wc -c < 'Makefile'`"
  101. then
  102.     echo shar: error transmitting "'Makefile'" '(should have been 1452 characters)'
  103. fi
  104. fi
  105. echo shar: extracting "'Makefile.lplot'" '(729 characters)'
  106. if test -f 'Makefile.lplot'
  107. then
  108.     echo shar: will not over-write existing file "'Makefile.lplot'"
  109. else
  110. cat << \SHAR_EOF > 'Makefile.lplot'
  111. # $Header: Makefile.lplot,v $
  112. # $Log: Makefile.lplot,v $
  113.  
  114. DEFINES=-DDEBUG -DBIGENDIAN
  115. CFLAGS = -O $(DEFINES)
  116. #CFLAGS = -pg $(DEFINES)
  117.  
  118. lplot:    global.o lplot.o read_stream.o \
  119.         functions.o iobuf.o alpha_plot.o
  120.         cc -o lplot $(CFLAGS) global.o lplot.o \
  121.         read_stream.o functions.o iobuf.o \
  122.         alpha_plot.o -lm 
  123.  
  124. clean:
  125.         rm -f *.o
  126.  
  127. copy:
  128.         cpr -n -s defs.h global.c extern.h io.h \
  129.         lplot.c read_stream.c functions.c iobuf.c \
  130.         alpha_plot.c | lprn
  131.  
  132. lint:
  133.         lint -ph $(DEFINES) global.c lplot.c \
  134.         read_stream.c functions.c iobuf.c \
  135.         alpha_plot.c
  136.  
  137. global.o:    defs.h io.h
  138. lplot.o:    defs.h extern.h io.h
  139. read_stream.o:    defs.h extern.h
  140. functions.o:    defs.h extern.h
  141. iobuf.o:    defs.h extern.h io.h
  142. alpha_plot.o:    extern.h
  143. SHAR_EOF
  144. if test 729 -ne "`wc -c < 'Makefile.lplot'`"
  145. then
  146.     echo shar: error transmitting "'Makefile.lplot'" '(should have been 729 characters)'
  147. fi
  148. fi
  149. echo shar: extracting "'Makefile.quick'" '(679 characters)'
  150. if test -f 'Makefile.quick'
  151. then
  152.     echo shar: will not over-write existing file "'Makefile.quick'"
  153. else
  154. cat << \SHAR_EOF > 'Makefile.quick'
  155. # $Header: Makefile.quick,v $
  156. # $Log: Makefile.quick,v $
  157.  
  158. DEFINES=-DQUICKPLOT -DDEBUG -DBIGENDIAN
  159. CFLAGS = -O $(DEFINES)
  160. #CFLAGS = -pg $(DEFINES)
  161.  
  162. quickplot:    global.o lplot.o read_stream.o functions.o iobuf.o
  163.     cc -o quickplot $(CFLAGS) global.o lplot.o read_stream.o \
  164.         functions.o iobuf.o -lm -ltermcap
  165.  
  166. clean:
  167.     rm -f *.o quickplot lplot
  168.  
  169. copy:
  170.     cpr -n -s defs.h global.c extern.h io.h lplot.c read_stream.c \
  171.     functions.c iobuf.c  | lprn
  172.  
  173. lint:
  174.     lint -ph $(DEFINES) global.c lplot.c read_stream.c \
  175.     functions.c iobuf.c 
  176.  
  177. global.o:    defs.h io.h
  178. lplot.o:    defs.h extern.h io.h
  179. read_stream.o:    defs.h extern.h
  180. functions.o:    defs.h extern.h
  181. iobuf.o:    defs.h extern.h io.h
  182. SHAR_EOF
  183. if test 679 -ne "`wc -c < 'Makefile.quick'`"
  184. then
  185.     echo shar: error transmitting "'Makefile.quick'" '(should have been 679 characters)'
  186. fi
  187. fi
  188. echo shar: extracting "'alpha_plot.c'" '(9282 characters)'
  189. if test -f 'alpha_plot.c'
  190. then
  191.     echo shar: will not over-write existing file "'alpha_plot.c'"
  192. else
  193. cat << \SHAR_EOF > 'alpha_plot.c'
  194. /* :set tabstops=4                                                    */
  195. static char *RCSid = "$Header: alpha_plot.c,v 1.1 86/04/20 16:16:28 sysad Exp $";
  196.  
  197. /*
  198.  * $Log:    alpha_plot.c,v $
  199.  * Revision 1.1  86/04/20  16:16:28  sysad
  200.  * Initial distribution version
  201.  * 
  202.  * 
  203.  */
  204.  
  205.  
  206. /* It is the intent of the author that this software may be distributed
  207.  * and used freely, without restriction.  If you make improvements or
  208.  * enhancements, I would appreciate a copy.
  209.  *
  210.  * Duane H. Hesser    Teltone Corporation
  211.  * ....uw-beaver!tikal!sysad
  212.  * ....uw-beaver!tikal!dhh
  213.  */
  214.  
  215. /* Character table for generation of ascii characters.
  216.  * Each row represents one character.  A nine high by eight wide
  217.  * matrix is used, including two descenders.  The first byte of
  218.  * each row is the "width" of the character; the remaining bytes
  219.  * are the bit pattern of the character, starting with the
  220.  * descenders (table[x][3] is the lower left corner of the character,
  221.  * which references the starting location of the character).
  222.  *
  223.  * Characters generated by lplot are rather severely restricted
  224.  * by the low dot density; as a result, labels will usually be
  225.  * "longer" in plotted length than those produced by other filters.
  226.  * The "width" includes the separation of the character from any
  227.  * following character (starting location of current character +
  228.  * width of current character = starting location of following
  229.  * character).  This is used to improve the appearance of labels,
  230.  * and reduce the problem of label size expansion.
  231.  */
  232. #include "extern.h"
  233.  
  234. char table[][10] = {
  235. 5, 0,    0,    0,    0,    0,    0,    0,    0,    0,      /* ' '   */
  236. 6, 0,    0,    040,  0,    040,  040,  040,  040,  040,    /*  '!'  */
  237. 5, 0,    0,    0,    0,    0,    0,    0,    0120, 0120,   /*  '"'  */
  238. 7, 0,    0,    0120, 0120, 0370, 0120, 0370, 0120, 0120,   /*  '#'  */
  239. 9, 0,    0,    020,  0374, 022,  0174, 0220, 0176, 020,    /*  '$'  */
  240. 9, 0,    0,    0204, 0112, 044,  020,  0110, 0244, 0102,   /*  '%'  */
  241. 8, 0,    0,    0144, 0230, 0220, 0250, 0104, 0240, 0100,   /*  '&'  */
  242. 3, 0,    0,    0,    0,    0,    0,    0200, 0100, 0100,   /*  '''  */
  243. 5, 0,    0,    040,  0100, 0200, 0200, 0200, 0100, 040,    /*  '('  */
  244. 5, 0,    0,    0200, 0100, 040,  040,  040,  0100, 0200,   /*  ')'  */
  245. 7, 0,    0,    0250, 0160, 0330, 0160, 0250, 0,    0,      /*  '*'  */
  246. 7, 0,    0,    040,  040,  0370, 040,  040,  0,    0,      /*  '+'  */
  247. 4, 0200, 0100, 0100, 0,    0,    0,    0,    0,    0,      /*  ','  */
  248. 7, 0,    0,    0,    0,    0,    0370, 0,    0,    0,      /*  '-'  */
  249. 3, 0,    0,    0200, 0,    0,    0,    0,    0,    0,      /*  '.'  */
  250. 9, 0,    0,    0200, 0100, 040,  020,  010,  04,   02,     /*  '/'  */
  251. 9, 0,    0,    070,  0104, 0202, 0202, 0202, 0104, 070,    /*  '0'  */
  252. 6, 0,    0,    0160, 0040, 0040, 0040, 0040, 0140, 0040,   /*  '1'  */
  253. 8, 0,    0,    0374, 0200, 0160, 010,  04,   0204, 0170,   /*  '2'  */
  254. 8, 0,    0,    0170, 0204, 04,   070,  04,   0204, 0170,   /*  '3'  */
  255. 8, 0,    0,    010,  010,  0374, 0210, 0110, 050,  010,    /*  '4'  */
  256. 8, 0,    0,    0160, 0210, 04,   010,  0360, 0200, 0370,   /*  '5'  */
  257. 8, 0,    0,    0170, 0204, 0204, 0370, 0100, 040,  020,    /*  '6'  */
  258. 8, 0,    0,    0100, 0100, 0100, 040,  020,  010,  0374,   /*  '7'  */
  259. 9, 0,    0,    070,  0104, 0202, 0104, 070,  0104, 070,    /*  '8'  */
  260. 8, 0,    0,    040,  020,  010,  0170, 0204, 0204, 0170,   /*  '9'  */
  261. 4, 0,    0,    0,    0300, 0,    0,    0300, 0,    0,      /*  ':'  */
  262. 5, 0,    0200, 0100, 0140, 0,    0140, 0,    0,    0,      /*  ';'  */
  263. 6, 0,    0,    020,  040,  0100, 0200, 0100, 040,  020,    /*  '<'  */
  264. 7, 0,    0,    0,    0,    0370, 0,    0370, 0,    0,      /*  '='  */
  265. 6, 0,    0,    0200, 0100, 040,  020,  040,  0100, 0200,   /*  '>'  */
  266. 8, 0,    0,    040,  0,    040,  020,  010,  0204, 0170,   /*  '?'  */
  267. 10,   0, 0,    076,  0100, 0236, 0245, 0231, 0102, 074,    /*  '@'  */
  268. 9, 0,    0,    0202, 0202, 0376, 0202, 0104, 050,  020,    /*  'A'  */
  269. 8, 0,    0,    0370, 0204, 0204, 0370, 0204, 0204, 0370,   /*  'B'  */
  270. 8, 0,    0,    0170, 0204, 0200, 0200, 0200, 0204, 0170,   /*  'C'  */
  271. 8, 0,    0,    0370, 0204, 0204, 0204, 0204, 0204, 0370,   /*  'D'  */
  272. 8, 0,    0,    0374, 0200, 0200, 0360, 0200, 0200, 0374,   /*  'E'  */
  273. 8, 0,    0,    0200, 0200, 0200, 0360, 0200, 0200, 0374,   /*  'F'  */
  274. 8, 0,    0,    0170, 0204, 0204, 0214, 0200, 0204, 0170,   /*  'G'  */
  275. 8, 0,    0,    0204, 0204, 0204, 0374, 0204, 0204, 0204,   /*  'H'  */
  276. 5, 0,    0,    0340, 0100, 0100, 0100, 0100, 0100, 0340,   /*  'I'  */
  277. 7, 0,    0,    0140, 0220, 020,  020,  020,  020,  070,    /*  'J'  */
  278. 8, 0,    0,    0204, 0210, 0220, 0340, 0220, 0210, 0204,   /*  'K'  */
  279. 8, 0,    0,    0374, 0200, 0200, 0200, 0200, 0200, 0200,   /*  'L'  */
  280. 9, 0,    0,    0202, 0202, 0202, 0222, 0252, 0306, 0202,   /*  'M'  */
  281. 9, 0,    0,    0202, 0206, 0212, 0222, 0242, 0302, 0202,   /*  'N'  */
  282. 8, 0,    0,    0170, 0204, 0204, 0204, 0204, 0204, 0170,   /*  'O'  */
  283. 8, 0,    0,    0200, 0200, 0200, 0370, 0204, 0204, 0370,   /*  'P'  */
  284. 8, 0,    0,    064,  0110, 0224, 0204, 0204, 0110, 060,    /*  'Q'  */
  285. 8, 0,    0,    0204, 0210, 0220, 0370, 0204, 0204, 0370,   /*  'R'  */
  286. 8, 0,    0,    0170, 0204, 04,   0170, 0200, 0204, 0170,   /*  'S'  */
  287. 6, 0,    0,    040,  040,  040,  040,  040,  040,  0370,   /*  'T'  */
  288. 9, 0,    0,    070,  0104, 0202, 0202, 0202, 0202, 0202,   /*  'U'  */
  289. 9, 0,    0,    020,  050,  0104, 0202, 0202, 0202, 0202,   /*  'V'  */
  290. 9, 0,    0,    0202, 0306, 0252, 0222, 0202, 0202, 0202,   /*  'W'  */
  291. 9, 0,    0,    0202, 0104, 050,  020,  050,  0104, 0202,   /*  'X'  */
  292. 9, 0,    0,    020,  020,  020,  020,  050,  0104, 0202,   /*  'Y'  */
  293. 8, 0,    0,    0374, 0200, 0100, 040,  020,  010,  0374,   /*  'Z'  */
  294. 5, 0,    0,    0340, 0200, 0200, 0200, 0200, 0200, 0340,   /*  '['  */
  295. 9, 0,    0,    02,   04,   010,  020,  040,  0100, 0200,   /*  '\'  */
  296. 5, 0,    0,    0340, 040,  040,  040,  040,  040,  0340,   /*  ']'  */
  297. 6, 0,    0,    0,    0,    0,    0,    0210, 0120, 040,    /*  '^'  */
  298. 8, 0,    0377, 0,    0,    0,    0,    0,    0,    0,      /*  '_'  */
  299. 4, 0,    0,    0,    0,    0,    0,    040,  040,  0100,   /*  '`'  */
  300. 8, 0,    0,    0164, 0210, 0170, 010,  0360, 0,    0,      /*  'a'  */
  301. 7, 0,    0,    0360, 0210, 0210, 0210, 0360, 0200, 0200,   /*  'b'  */
  302. 7, 0,    0,    0170, 0200, 0200, 0200, 0170, 0,    0,      /*  'c'  */
  303. 8, 0,    0,    0164, 0210, 0210, 0210, 0170, 010,  010,    /*  'd'  */
  304. 8, 0,    0,    0170, 0200, 0370, 0204, 0170, 0,    0,      /*  'e'  */
  305. 6, 0,    0,    0100, 0100, 0100, 0340, 0100, 0110, 060,    /*  'f'  */
  306. 7, 0360, 010,  0170, 0210, 0210, 0210, 0160, 0,    0,      /*  'g'  */
  307. 7, 0,    0,    0210, 0210, 0210, 0210, 0360, 0200, 0200,   /*  'h'  */
  308. 5, 0,    0,    0340, 0100, 0100, 0100, 0300, 0,    0100,   /*  'i'  */
  309. 7, 0140, 0220, 020,  020,  020,  020,  020,  0,    020,    /*  'j'  */
  310. 7, 0,    0,    0210, 0220, 0240, 0300, 0240, 0220, 0200,   /*  'k'  */
  311. 5, 0,    0,    0340, 0100, 0100, 0100, 0100, 0100, 0300,   /*  'l'  */
  312. 9, 0,    0,    0222, 0222, 0222, 0222, 0356, 0,    0,      /*  'm'  */
  313. 8, 0,    0,    0104, 0104, 0104, 0104, 0270, 0,    0,      /*  'n'  */
  314. 7, 0,    0,    0160, 0210, 0210, 0210, 0160, 0,    0,      /*  'o'  */
  315. 7, 0200, 0200, 0360, 0210, 0210, 0210, 0360, 0,    0,      /*  'p'  */
  316. 7, 010,  010,  0170, 0210, 0210, 0210, 0170, 0,    0,      /*  'q'  */
  317. 6, 0,    0,    0200, 0200, 0200, 0310, 0260, 0,    0,      /*  'r'  */
  318. 7, 0,    0,    0360, 010,  0160, 0200, 0170, 0,    0,      /*  's'  */
  319. 7, 0,    0,    020,  050,  040,  040,  0370, 040,  040,    /*  't'  */
  320. 8, 0,    0,    0164, 0210, 0210, 0210, 0210, 0,    0,      /*  'u'  */
  321. 8, 0,    0,    040,  0120, 0210, 0210, 0210, 0,    0,      /*  'v'  */
  322. 9, 0,    0,    0104, 0252, 0222, 0222, 0202, 0,    0,      /*  'w'  */
  323. 8, 0,    0,    0210, 0120, 040,  0120, 0210, 0,    0,      /*  'x'  */
  324. 8, 0360, 010,  0170, 0210, 0210, 0210, 0210, 0,    0,      /*  'y'  */
  325. 8, 0,    0,    0370, 0100, 040,  020,  0370, 0,    0,      /*  'z'  */
  326. 6, 0,    0,    060,  0100, 0100, 0200, 0100, 0100, 060,    /*  '{'  */
  327. 3, 0,    0,    0200, 0200, 0200, 0,    0200, 0200, 0200,   /*  '|'  */
  328. 7, 0,    0,    0300, 040,  040,  020,  040,  040,  0300,   /*  '}'  */
  329. 7, 0,    0,    0,    0,    0,    0,    020,  0250, 0100,   /*  '~'  */
  330. 7, 0,    0,    040,  0160, 0250, 040,  040,  0,    0,      /*  'd'  */
  331. };
  332.  
  333. alpha_plot(c)
  334. char c;
  335. {
  336.     int width;
  337.     int index = c - ' ';
  338.     char *ptr;
  339.     short x,y,i,j;
  340.  
  341.     if((index < 0) || (index >= sizeof(table))) return;
  342.  
  343.     ptr = table[index];
  344.     width = ((int)*ptr++ & 0377);
  345.  
  346.     /* Move so that the character is plotted with its center (approx)
  347.      * is plotted at the current point.  We have to undo this at the
  348.      * end.
  349.      */
  350.     curxdot -= 3;
  351.     curydot -= 3;
  352.     /* this is a hack--character height changes due to different
  353.      * dot densities in x and y.  we restore this at the end.
  354.      */
  355.     if(Rotate) --curydot;
  356.     
  357.     for(i = 0;i < 9; ++i)
  358.     {
  359.         if(ptr[i])
  360.         {
  361.             for(j = 0; j < 8; ++j)
  362.             {
  363.                 if(plotbit(ptr[i],j))
  364.                 {
  365.                     x = curxdot + 7 - j;
  366.                     y = curydot + i - 2;
  367.                     point(x,y);
  368.                 }
  369.             }
  370.         }
  371.     }
  372.     if(Rotate)
  373.     {
  374.         /* different dot densities, again                            */
  375.         width = (double)width * YPERINCH / XPERINCH;
  376.         curydot++;    /* end hack                                        */
  377.     }
  378.     curx += (double)width/mapxfac;
  379.     curxdot += 3;
  380.     curydot += 3;
  381.     curxdot += width;
  382. }
  383. SHAR_EOF
  384. if test 9282 -ne "`wc -c < 'alpha_plot.c'`"
  385. then
  386.     echo shar: error transmitting "'alpha_plot.c'" '(should have been 9282 characters)'
  387. fi
  388. fi
  389. echo shar: extracting "'functions.c'" '(11457 characters)'
  390. if test -f 'functions.c'
  391. then
  392.     echo shar: will not over-write existing file "'functions.c'"
  393. else
  394. cat << \SHAR_EOF > 'functions.c'
  395. /* :set tabstops=4                                                    */
  396. static char *RCSid = "$Header: functions.c,v 1.1 86/04/20 16:16:38 sysad Exp $";
  397.  
  398. /*
  399.  * $Log:    functions.c,v $
  400.  * Revision 1.1  86/04/20  16:16:38  sysad
  401.  * Initial distribution version
  402.  * 
  403.  * 
  404.  */
  405.  
  406.  
  407. /* It is the intent of the author that this software may be distributed
  408.  * and used freely, without restriction.  If you make improvements or
  409.  * enhancements, I would appreciate a copy.
  410.  *
  411.  * Duane H. Hesser    Teltone Corporation
  412.  * ....uw-beaver!tikal!sysad
  413.  * ....uw-beaver!tikal!dhh
  414.  */
  415.  
  416. #include "defs.h"
  417. #include "extern.h"
  418.  
  419. space(x0,y0,x1,y1)
  420. short x0,y0,x1,y1;
  421. {
  422.     static int noinit = 1;
  423.     double tmp;
  424.  
  425. #ifdef DEBUG
  426.     if(debug & 1) printf("space(%d,%d,%d,%d)\n",x0,y0,x1,y1);
  427. #endif
  428.     lowx_space = (double)x0;
  429.     lowy_space = (double)y0;
  430.     highx_space = (double)x1;
  431.     highy_space = (double)y1;
  432.     xspace = highx_space - lowx_space;
  433.     yspace = highy_space - lowy_space;
  434.     if(maxcol > XDOTS) maxcol = XDOTS;
  435.     if(maxrow > YDOTS) maxrow = YDOTS;
  436. #ifdef QUICKPLOT
  437.     /* Autowrap can be a problem; some terminals and/or screen packages
  438.      * wrap early (i.e., they wrap when the last character is
  439.      * placed in the row, rather than waiting for the next character.
  440.      * Safest way seems to be to waste a column.
  441.      */
  442.     if(autowrap) maxcol--;
  443. #endif
  444.     maxx = maxcol - 1;
  445.     maxy = maxrow - 1;
  446.     if(Rotate)
  447.     {
  448.         if(noinit)
  449.         {
  450.             noinit = 0;
  451.             tmp = spacex;
  452.             spacex = spacey;
  453.             spacey = tmp;
  454.             tmp = maxx;
  455.             maxx = maxy;
  456.             maxy = tmp;
  457.             /* re-compute the margins */
  458.             tmp = (Xmargin / XPERINCH) * YPERINCH;
  459.             Xmargin = (Ymargin / YPERINCH) * XPERINCH;
  460.             Ymargin = tmp;
  461.         }
  462.     }
  463.     if(spacex > maxx) spacex = maxx;
  464.     if(spacey > maxy) spacey = maxy;
  465.     xfac = ( spacex/xspace ) * argxfac;
  466.     yfac = ( spacey/yspace ) * argyfac;
  467.     mapxfac = xfac * Scalfac;
  468.     mapyfac = yfac * Scalfac;
  469. #ifdef DEBUG
  470.     if(debug &2)
  471.     {
  472.         printf("maxrow=%d,maxcol=%d,maxx=%d,maxy=%d\n",maxrow,maxcol,maxx,maxy);
  473.         printf("xfac=%G,yfac=%G,mapxfac=%G,mapyfac=%G\n",xfac,yfac,mapxfac,mapyfac);
  474.         printf("spacex=%G,spacey=%G,xspace=%G,yspace=%G\n",spacex,spacey,xspace,yspace);
  475.     }
  476. #endif
  477. }
  478.  
  479. cont(x,y)
  480. short x,y;
  481. {
  482.     x = (short)mapx(x);
  483.     y = (short)mapy(y);
  484.     make_line(curxdot,curydot,x,y);
  485.     curxdot = x;
  486.     curydot = y;
  487. #ifdef DEBUG
  488.     if(debug & 1) printf("cont(%d,%d)\n",curxdot,curydot);
  489. #endif
  490. }
  491.  
  492. move(x,y)
  493. short x,y;
  494. {
  495.     curxdot = (short)mapx(x);
  496.     curydot = (short)mapy(y);
  497. #ifdef DEBUG
  498.     if(debug & 1) printf("move(%d,%d)\n",curxdot,curydot);
  499. #endif
  500. }
  501.  
  502. line(x0,y0,x1,y1)
  503. short x0,y0,x1,y1;
  504. {
  505.     x0 = (short)mapx(x0);
  506.     x1 = (short)mapx(x1);
  507.     y0 = (short)mapy(y0);
  508.     y1 = (short)mapy(y1);
  509.     make_line(x0,y0,x1,y1);
  510. #ifdef DEBUG
  511.     if(debug & 1) printf("line(%d,%d,%d,%d)\n",x0,y0,x1,y1);
  512. #endif
  513.     curxdot = x1;
  514.     curydot = y1;
  515. }
  516.  
  517. make_line(x0,y0,x1,y1)
  518. short x0,y0,x1,y1;
  519. {
  520.     short xdots,ydots,i,j,signx,signy;
  521.     double tanxy;
  522. #ifdef QUICKPLOT
  523.     char pc = plotchar;
  524. #endif
  525.  
  526.     xdots = x1 - x0;
  527.     ydots = y1 - y0;
  528.     signx = (xdots > 0) ? 1 : -1;
  529.     signy = (ydots > 0) ? 1 : -1;
  530.     point(x0,y0);
  531.     if(xdots == 0)
  532.     {
  533.         if(ydots == 0) return;
  534.         for(i = signy; i != ydots; i += signy)
  535.         {
  536. #ifndef QUICKPLOT
  537.             if(!(abs(i) & linemask)) continue;
  538. #else
  539.             if(abs(i) & 1) plotchar = linemask;
  540.             else plotchar = pc;
  541. #endif
  542.             point(x0,y0 + i);
  543.         }
  544.     }
  545.     else if(ydots == 0)
  546.     {
  547.         for(i = signx; i != xdots; i += signx)
  548.         {
  549. #ifndef QUICKPLOT
  550.             if(!(abs(i) & linemask)) continue;
  551. #else
  552.             if(abs(i) & 1) plotchar = linemask;
  553.             else plotchar = pc;
  554. #endif
  555.             point(x0 + i,y0);
  556.         }
  557.     }
  558.     else if(abs(xdots) >= abs(ydots))
  559.     {
  560.         tanxy = (double)ydots / (double)xdots;
  561.         for(i = signx; i != xdots; i += signx)
  562.         {
  563. #ifndef QUICKPLOT
  564.             if(!(abs(i) & linemask)) continue;
  565. #else
  566.             if(abs(i) & 1) plotchar = linemask;
  567.             else plotchar = pc;
  568. #endif
  569.             j = i * tanxy;
  570.             point(x0 + i,y0 + j);
  571.         }
  572.     }
  573.     else
  574.     {
  575.         tanxy = (double)xdots / (double)ydots;
  576.         for(i = signy; i != ydots; i += signy)
  577.         {
  578. #ifndef QUICKPLOT
  579.             if(!(abs(i) & linemask)) continue;
  580. #else
  581.             if(abs(i) & 1) plotchar = linemask;
  582.             else plotchar = pc;
  583. #endif
  584.             j = i * tanxy;
  585.             point(x0 + j,y0 + i);
  586.         }
  587.     }
  588.     point(x1,y1);
  589. #ifdef QUICKPLOT
  590.     plotchar = pc;
  591. #endif
  592. }
  593.  
  594.  
  595. circle(x,y,r)
  596. short x,y,r;
  597. {
  598.     short x0;
  599.  
  600.     x0 = x + r;
  601.     arc(x,y,x0,y,x0,y);
  602.     move(x,y);
  603. }
  604.  
  605. label(str,len)
  606. char *str;
  607. int len;
  608. {
  609.     int i;
  610.     char *rp;
  611.  
  612. #ifdef DEBUG
  613.     if(debug & 1) printf("label(%s,%d)\n",str,len);
  614. #endif
  615.     for(i=0; i < len && str[i] != '\n'; i++) 
  616.     {
  617.         if((str[i] < ' ') || (str[i] >= '\177')) continue;
  618. #ifndef QUICKPLOT
  619.         alpha_plot(str[i]);
  620. #else
  621.         if(Rotate)
  622.         {
  623.             rp = &Row[curxdot][maxy-curydot];
  624.             if(*rp && (*rp != plotchar))  ++curxdot;
  625.             Row[curxdot][maxy-curydot] = str[i];
  626.         }
  627.         else
  628.         {
  629.             rp = &Row[curydot][curxdot];
  630.             if(*rp && (*rp != plotchar))  ++curxdot;
  631.             Row[curydot][curxdot] = str[i];
  632.         }
  633. #endif
  634.     }
  635. }
  636.  
  637. #ifndef QUICKPLOT
  638. point(x,y)
  639. short x,y;
  640. {
  641.     short row,byte,bit;
  642.     if(x > maxx)
  643.     {
  644.         x = maxx;
  645.     }
  646.     else if(x < 0)
  647.     {
  648.         x = 0;
  649.     }
  650.     if(y > maxy)
  651.     {
  652.         y = maxy;
  653.     }
  654.     else if(y < 0)
  655.     {
  656.         y = 0;
  657.     }
  658.  
  659.     if(Rotate)
  660.     {
  661.         row = x;
  662.         byte = (maxy - y) / 6;
  663.         bit = 5 - (y % 6);
  664.     }
  665.     else
  666.     {
  667.         row = y;
  668.         byte = x/6;
  669.         bit = x%6;
  670.     }
  671.     Row[row][byte] |= BIT[bit];
  672. }
  673.  
  674. #else QUICKPLOT
  675.  
  676. point(x,y)
  677. short x,y;
  678. {
  679.     short row,col;
  680.     char pc;
  681.  
  682.     pc = plotchar;
  683.     if(x > maxx)
  684.     {
  685.         x = maxx;
  686.         pc = '@';
  687.     }
  688.     else if(x < 0)
  689.     {
  690.         x = 0;
  691.         pc = '@';
  692.     }
  693.     if(y > maxy)
  694.     {
  695.         y = maxy;
  696.         pc = '@';
  697.     }
  698.     else if(y < 0)
  699.     {
  700.         y = 0;
  701.         pc = '@';
  702.     }
  703.  
  704.     if(Rotate)
  705.     {
  706.         row = x;
  707.         col = maxy - y;
  708.     }
  709.     else
  710.     {
  711.         row = y;
  712.         col = x;
  713.     }
  714.     if(!Row[row][col]) Row[row][col] = pc;
  715. }
  716. #endif QUICKPLOT
  717.  
  718. /* Make an arc with (x,y) as center, (x0,y0) as starting point,
  719.  * and (x1,y1) as end point.
  720.  *
  721.  * The algorithm here is simpler than it looks; the intent is to
  722.  * compute the points required just once in the first quadrant,
  723.  * then reflect them across the axes or origin if they are required
  724.  * in the other quadrants.
  725.  * 1. Find the starting and ending quadrants.
  726.  * 2. Verify the end point, and make sure it is on the arc thru (x0,y0)
  727.  *    with center (x,Y).
  728.  * 3. Determine which quadrants require points to be plotted.
  729.  * 4. Determine the minimum and maximum "y" deltas in each quadrant.
  730.  *    and set the starting point for line drawing in each quadrant.
  731.  * 5. Pot the arc by incrementing the delta "y" and computing the
  732.  *    corresponding "x" delta in the first quadrant.  Then check each
  733.  *    quadrant to see if the corresponding point is needed, and draw a
  734.  *    line from the last point plotted in that quadrant to the current
  735.  *    point in that quadrant.
  736.  */
  737. #include <math.h>
  738. arc(x,y,x0,y0,x1,y1)
  739. short x,y,x0,y0,x1,y1;
  740. {
  741.     int i,ystart,ymax,dx,dy,sq,endq,nq;
  742.     int q[4],qmin[4],qmax[4];
  743.     short lx[4],ly[4],nx,ny,r,rx,ry;
  744.     double asin(),sin(),cos(),ra,theta;
  745.  
  746. #ifdef DEBUG
  747.     if(debug & 3)
  748.         printf("to arc(%d,%d,%d,%d,%d,%d)\n",x,y,x0,y0,x1,y1);
  749. #endif
  750.     /* find starting quadrant                                        */
  751.     if(y0 >= y)
  752.     {
  753.         if(x0 > x) sq = 1;
  754.         else if(y0 == y) sq = 3;
  755.         else sq = 2;
  756.     }
  757.     else if(x0 >= x) sq = 4;
  758.     else sq = 3;
  759.     /* find ending quadrant                                            */
  760.     if(x1 >= x)
  761.     {
  762.         if(y1 > y) endq = 1;
  763.         else if(x1 == x) endq = 3;
  764.         else endq = 4;
  765.     }
  766.     else if(y1 >= y) endq = 2;
  767.     else endq = 3;
  768.  
  769.     /* The calling program can easily pass a phony x1,y1 which
  770.      * doesn't lie on the arc thru x0,y0 with center x,y.
  771.      * Fix it.
  772.      */
  773.     dx = abs(x0 - x); dy = abs(y0 - y);
  774.     if(dx == 0)
  775.     {
  776.         if(dy == 0) return;    /* 0 radius; that's easy            */
  777.         r = dy;
  778.     }
  779.     else if(dy == 0) r = dx;
  780.     else
  781.     {
  782.         r = sqrt(((double)dx * (double)dx) + ((double)dy * (double)dy));
  783.         /* r should never be <= 0, unless integer truncation occurs    */
  784.         if(r <= 0) r = 1;
  785.     }
  786.  
  787.     ra = (double)abs(y1 - y) / (double)r;
  788.     theta = asin(ra);
  789.     dx = r * cos(theta) + 0.5;
  790.     dy = r * sin(theta) + 0.5;
  791.     /* make sure these are positive                                    */
  792.     if((dx == 0) && (dy == 0)) return;
  793.     r = abs((int)r);
  794.     dx = abs(dx);
  795.     dy = abs(dy);
  796.  
  797.     if(debug & 3) printf("dx=%d,dy=%d\n",dx,dy);
  798.     if(endq & 2) x1 = x - dx;
  799.     else x1 = x + dx;
  800.     if(endq > 2) y1 = y - dy;
  801.     else y1 = y + dy;
  802.     if(debug & 3) printf("x1=%d,y1=%d\n",x1,y1);
  803.  
  804.     /* Map to device units.  Radius is mapped for both x direction
  805.      * and y direction because resolution differs in the two directions.
  806.      */
  807.     x = (short)mapx(x);
  808.     x0 = (short)mapx(x0);
  809.     x1 = (short)mapx(x1);
  810.     y = (short)mapy(y);
  811.     y0 = (short)mapy(y0);
  812.     y1 = (short)mapy(y1);
  813.     rx = (short)(((double)r * mapxfac) + .01);
  814.     ry = (short)(((double)r * mapyfac) + .01);
  815.  
  816.     /* Mark the quadrants which require plotting.
  817.      * Note that quadrants are numbered from 1-4, just like in math
  818.      * class, but the "q" arrays run from 0-3
  819.      */
  820.     q[0] = q[1] = q[2] = q[3] = 0;
  821.     if(sq <= endq)
  822.     {
  823.         for(i = sq; i <= endq; ++i)
  824.         {
  825.             ++q[i - 1];
  826.             nq++;        /* number of quadrants                        */
  827.         }
  828.     }
  829.     else
  830.     {
  831.         for(i = sq; i <= 4; ++i)
  832.         {
  833.             ++q[i - 1];
  834.             nq++;
  835.         }
  836.         for(i = 1; i <= endq; ++i)
  837.         {
  838.             ++q[i - 1];
  839.             nq++;
  840.         }
  841.     }
  842.     if(debug & 1)
  843.     {
  844.         printf("arc(%d,%d,%d,%d,%d,%d)\n",x,y,x0,y0,x1,y1);
  845.         printf("(radius=%d,%d,%d)\n",r,rx,ry);;
  846.     }
  847.  
  848.     /* find the min and max y increments                            */
  849.     if(nq >= 3)
  850.     {
  851.         ystart = 0;
  852.         ymax = ry;
  853.     }
  854.     else if(nq == 1)
  855.     {
  856.         if((sq == 1) || (sq == 3))
  857.         {
  858.             ystart = abs(y0 - y);
  859.             ymax = abs(y1 - y);
  860.         }
  861.         else
  862.         {
  863.             ymax = abs(y0 - y);
  864.             ystart = abs(y1 - y);
  865.         }
  866.     }
  867.     else if((sq + endq) == 5)    /* 1 & 4 or 2 & 3                    */
  868.     {
  869.         ystart = 0;
  870.         ymax = (abs(y0 - y) > abs(y1 - y)) ? abs(y0 - y) : abs(y1 - y);
  871.     }
  872.     else
  873.     {
  874.         ymax = ry;
  875.         ystart = (abs(y0 - y) > abs(y1 - y)) ? abs(y1 - y) : abs(y0 - y);
  876.     }
  877.     /* now find the min and max y increments for each quadrant        */
  878.     if(q[0])        /* 1st quadrant                                    */
  879.     {
  880.         if(sq == 1)
  881.         {
  882.             qmin[0] = y0 - y;
  883.             ly[0] = y0;
  884.             lx[0] = x0;
  885.         }
  886.         else
  887.         {
  888.             qmin[0] = 0;
  889.             ly[0] = y;
  890.             lx[0] = x + rx;
  891.         }
  892.         if(endq == 1) qmax[0] = y1 - y;
  893.         else qmax[0] = ry;
  894.     }
  895.     if(q[1])        /* 2nd quadrant                                    */
  896.     {
  897.         if(sq == 2)
  898.         {
  899.             qmax[1] = y0 - y;
  900.         }
  901.         else
  902.         {
  903.             qmax[1] = ry;
  904.         }
  905.         if(endq == 2)
  906.         {
  907.             qmin[1] = y1 - y;
  908.             ly[1] = y1;
  909.             lx[1] = x1;
  910.         }
  911.         else
  912.         {
  913.             qmin[1] = 0;
  914.             ly[1] = y;
  915.             lx[1] = x - rx;
  916.         }
  917.     }
  918.     if(q[2])        /* 3rd    quadrant                                */
  919.     {
  920.         if(sq == 3)
  921.         {
  922.             qmin[2] = y - y0;
  923.             ly[2] = y0;
  924.             lx[2] = x0;
  925.         }
  926.         else
  927.         {
  928.             qmin[2] = 0;
  929.             ly[2] = y;
  930.             lx[2] = x - rx;
  931.         }
  932.         if(endq == 3)
  933.         {
  934.             qmax[2] = y - y1;
  935.         }
  936.         else
  937.         {
  938.             qmax[2] = ry;
  939.         }
  940.     }
  941.     if(q[3])        /* 4th quadrant                                    */
  942.     {
  943.         if(sq == 4)
  944.         {
  945.             qmax[3] = y - y0;
  946.         }
  947.         else
  948.         {
  949.             qmax[3] = ry;
  950.         }
  951.         if(endq == 4)
  952.         {
  953.             qmin[3] = y - y1;
  954.             ly[3] = y1;
  955.             lx[3] = x1;
  956.         }
  957.         else
  958.         {
  959.             qmin[3] = 0;
  960.             ly[3] = y;
  961.             lx[3] = x + rx;
  962.         }
  963.     }
  964. #ifdef DEBUG
  965.     if(debug & 3)
  966.     {
  967.         printf("sq=%d,endq=%d,ystart=%d,ymax=%d\n",sq,endq,ystart,ymax);
  968.         printf("q\t  min \t  max \t  lx  \t  ly\n");
  969.         for(i=0; i < 4; ++i)
  970.         {
  971.             if(q[i])
  972.                 printf("%d\t%d\t%d\t%d\t%d\n",i+1,qmin[i],qmax[i],lx[i],ly[i]);
  973.         }
  974.     }
  975. #endif DEBUG
  976.     /* finally ready to plot                                        */
  977.     for(i = ystart; i <= ymax; ++i)
  978.     {
  979.         ra = ry ? (double)i / (double)ry: 0;
  980.         theta = asin(ra);
  981.         dx = (double)rx * cos(theta) + 0.5;
  982.         if(q[0] && (i >= qmin[0]) && (i <= qmax[0]))
  983.         {
  984.             nx = x + dx;
  985.             ny = y + i;
  986.             make_line(lx[0],ly[0],nx,ny);
  987.             lx[0] = nx;
  988.             ly[0] = ny;
  989.         }
  990.         if(q[1] && (i >= qmin[1]) && (i <= qmax[1]))
  991.         {
  992.             nx = x - dx;
  993.             ny = y + i;
  994.             make_line(lx[1],ly[1],nx,ny);
  995.             lx[1] = nx;
  996.             ly[1] = ny;
  997.         }
  998.         if(q[2] && (i >= qmin[2]) && (i <= qmax[2]))
  999.         {
  1000.             nx = x - dx;
  1001.             ny = y - i;
  1002.             make_line(lx[2],ly[2],nx,ny);
  1003.             lx[2] = nx;
  1004.             ly[2] = ny;
  1005.         }
  1006.         if(q[3] && (i >= qmin[3]) && (i <= qmax[3]))
  1007.         {
  1008.             nx = x + dx;
  1009.             ny = y - i;
  1010.             make_line(lx[3],ly[3],nx,ny);
  1011.             lx[3] = nx;
  1012.             ly[3] = ny;
  1013.         }
  1014.     }
  1015. }
  1016. SHAR_EOF
  1017. if test 11457 -ne "`wc -c < 'functions.c'`"
  1018. then
  1019.     echo shar: error transmitting "'functions.c'" '(should have been 11457 characters)'
  1020. fi
  1021. fi
  1022. echo shar: extracting "'global.c'" '(2962 characters)'
  1023. if test -f 'global.c'
  1024. then
  1025.     echo shar: will not over-write existing file "'global.c'"
  1026. else
  1027. cat << \SHAR_EOF > 'global.c'
  1028. /* :set tabstops=4                                                    */
  1029. static char *RCSid = "$Header: global.c,v 1.1 86/04/20 16:16:41 sysad Exp $";
  1030.  
  1031. /*
  1032.  * $Log:    global.c,v $
  1033.  * Revision 1.1  86/04/20  16:16:41  sysad
  1034.  * Initial distribution version
  1035.  * 
  1036.  * 
  1037.  */
  1038.  
  1039.  
  1040. /* It is the intent of the author that this software may be distributed
  1041.  * and used freely, without restriction.  If you make improvements or
  1042.  * enhancements, I would appreciate a copy.
  1043.  *
  1044.  * Duane H. Hesser    Teltone Corporation
  1045.  * ....uw-beaver!tikal!sysad
  1046.  * ....uw-beaver!tikal!dhh
  1047.  */
  1048.  
  1049. #include "defs.h"
  1050. #include "io.h"
  1051.  
  1052. /* This is the output array; it should be big enough for the largest
  1053.  * "raster" which will be used (currently the full size of an 11 x 13.2
  1054.  * inch line printer page).
  1055.  */
  1056. char Row[YDOTS][XARRAYSIZE];
  1057. #ifndef QUICKPLOT
  1058. /* These are the bits which are or'ed into the output array to acivate
  1059.  * the appropriate hammers.
  1060.  */
  1061. char BIT[] = {
  1062.     '\001','\002','\004','\010','\020','\040','\100','\0'
  1063. };
  1064. #else
  1065. char plotchar = PLOTCHAR;
  1066. int autowrap = 0;            /* does the terminal auto-wrap at eol?    */
  1067. #endif
  1068.  
  1069. /* Initially, we map everything into an 8 inch square for lplot,
  1070.  * or into a 132 wide x 66 line "screen" for quickplot.  The 8 inch
  1071.  * square for lplot is consistent with scaling for things like
  1072.  * "vplot" which plot onto an 8 1/2 x 11 inch page.
  1073.  * The values initialized may be changed (within array size limits
  1074.  * by program arguments, and will take effect at the first space()
  1075.  * call.
  1076.  */
  1077. double spacex = SPACEX;
  1078. double spacey = SPACEY;
  1079.  
  1080. /* These are the program units which will map into spacex & spacey
  1081.  * after the space() call.
  1082.  */
  1083. double xspace,yspace;
  1084.  
  1085. /* min and max points mapped into the plotting space by space()        */
  1086. double highx_space,highy_space,lowx_space,lowy_space;
  1087.  
  1088. /* maximum dots each direction; truncate larger values.                */
  1089. int maxrow = YDOTS;
  1090. int maxcol = XDOTS;
  1091. /* maximum x and y values; generally one less than maxrow, maxcol    */
  1092. int maxx = MAXX;
  1093. int maxy = MAXY;
  1094.  
  1095. /* current coordinates in program units and dots                    */
  1096. short curx,cury,curxdot,curydot;
  1097.  
  1098. double Scalfac = 1.0;            /* settable overall scale factor    */
  1099. double xfac = 1.0;                /* scale factor for x                */
  1100. double yfac = 1.0;                /* scale factor for y                */
  1101. double argxfac = 1.0;            /* argument scale factor for x        */
  1102. double argyfac = 1.0;            /* argument scale factor for y        */
  1103. double mapxfac = 1.0;            /* final mapping factor for x         */
  1104. double mapyfac = 1.0;            /* final mapping factor for y        */
  1105. double Xmargin = 0.0;            /* settable left margin in pixels    */
  1106. double Ymargin = 0.0;            /* settable bottom margin in pixels    */
  1107.  
  1108. int Plotdata = 0;                /* set when raster is ready to send    */
  1109. int Eflag = 0;                    /* force erase before each plot        */
  1110. int Nflag = 0;                    /* suppress erasing while in effect    */
  1111. #ifdef QUICKPLOT
  1112. int linemask = PLOTCHAR;        /* solid, dotted, dashed, etc.        */
  1113. #else
  1114. int linemask = SOLID;            /* solid, dotted, dashed, etc.        */
  1115. #endif
  1116.  
  1117. char *Name;
  1118. int debug = 0;
  1119.  
  1120. #ifndef QUICKPLOT
  1121. int Npages = 0;
  1122. #endif
  1123. int Rotate = 0;
  1124. SHAR_EOF
  1125. if test 2962 -ne "`wc -c < 'global.c'`"
  1126. then
  1127.     echo shar: error transmitting "'global.c'" '(should have been 2962 characters)'
  1128. fi
  1129. fi
  1130. echo shar: extracting "'iobuf.c'" '(2781 characters)'
  1131. if test -f 'iobuf.c'
  1132. then
  1133.     echo shar: will not over-write existing file "'iobuf.c'"
  1134. else
  1135. cat << \SHAR_EOF > 'iobuf.c'
  1136. /* :set tabstops=4                                                    */
  1137. static char *RCSid = "$Header: iobuf.c,v 1.1 86/04/20 16:16:43 sysad Exp $";
  1138.  
  1139. /*
  1140.  * $Log:    iobuf.c,v $
  1141.  * Revision 1.1  86/04/20  16:16:43  sysad
  1142.  * Initial distribution version
  1143.  * 
  1144.  * 
  1145.  */
  1146.  
  1147. /* An utterly simple buffering scheme; it's all we need.            */
  1148.  
  1149. /* It is the intent of the author that this software may be distributed
  1150.  * and used freely, without restriction.  If you make improvements or
  1151.  * enhancements, I would appreciate a copy.
  1152.  *
  1153.  * Duane H. Hesser    Teltone Corporation
  1154.  * ....uw-beaver!tikal!sysad
  1155.  * ....uw-beaver!tikal!dhh
  1156.  */
  1157.  
  1158. #include    "io.h"
  1159.  
  1160. bufopen(file,io)
  1161. char *file;
  1162. struct inbuf *io;
  1163. {
  1164.  
  1165.     if((io->fd = open(file,0)) < 0)
  1166.         return(-1);
  1167.     io->nleft = 0;
  1168.     io->eof = 0;
  1169.     return(io->fd);
  1170. }
  1171.  
  1172. bufclose(io)
  1173. struct inbuf *io;
  1174. {
  1175.     if(io->fd >= 0) close(io->fd);
  1176.     io->eof = 1;
  1177.     io->nleft = 0;
  1178.     io->fd = -1;
  1179. }
  1180.  
  1181. char
  1182. getbyte(io)
  1183. struct inbuf *io;
  1184. {
  1185.     char next,ebuf[32];
  1186.  
  1187.     if(io->nleft <= 0)
  1188.     {
  1189.         if(io->fd < 0)
  1190.         {
  1191.             sprintf(ebuf,"%s: unopen file error in getbyte()\n");
  1192.             write(2,ebuf,strlen(ebuf));
  1193.             exit(69);
  1194.         }
  1195.         io->nleft = read(io->fd,io->buff,INBUFSIZE);
  1196.         if(io->nleft < 0)
  1197.         {
  1198.             sprintf(ebuf,"%s: read error in getbyte()\n");
  1199.             write(2,ebuf,strlen(ebuf));
  1200.             exit(69);
  1201.         }
  1202.         io->nextp = io->buff;
  1203.     }
  1204.     if(io->nleft-- <= 0)
  1205.     {
  1206.         io->eof++;
  1207.         return('\0');
  1208.     }
  1209.     next = *(io->nextp++) & '\377';
  1210.     return(next);
  1211. }
  1212.  
  1213.  
  1214.  
  1215. getstr(io,buf)
  1216. struct inbuf *io;
  1217. char *buf;
  1218. {
  1219.     char *ptr = buf;
  1220.     char getbyte();
  1221.  
  1222.     while( *ptr = getbyte(io) )
  1223.     {
  1224.         if(*ptr++ == '\n')
  1225.         {
  1226.             *--ptr = '\0';
  1227.             break;
  1228.         }
  1229.     }
  1230.     return(strlen(buf));
  1231. }
  1232.  
  1233.  
  1234. #ifdef BIGENDIAN
  1235. union {
  1236.     short sh_word;
  1237.     struct {
  1238.         char hi_byte;
  1239.         char lo_byte;
  1240.     } sh_bytes;
  1241. } sh;
  1242. #else
  1243. union {
  1244.     short sh_word;
  1245.     struct {
  1246.         char lo_byte;
  1247.         char hi_byte;
  1248.     } sh_bytes;
  1249. } sh;
  1250. #endif
  1251. short
  1252. getshort(io)
  1253. struct inbuf *io;
  1254. {
  1255.     char c,ebuf[32];
  1256.  
  1257.     c = getbyte(io);
  1258.     if(eof(io))
  1259.     {
  1260.         sprintf(ebuf,"unexpected EOF in getshort()\n");
  1261.         write(2,ebuf,strlen(ebuf));
  1262.         exit(69);
  1263.     }
  1264.     else sh.sh_bytes.lo_byte = c;
  1265.  
  1266.     c = getbyte(io);
  1267.     if(eof(io))
  1268.     {
  1269.         sprintf(ebuf,"unexpected EOF in getshort()\n");
  1270.         write(2,ebuf,strlen(ebuf));
  1271.         exit(69);
  1272.     }
  1273.     else sh.sh_bytes.hi_byte = c;
  1274.     return(sh.sh_word);
  1275. }
  1276.  
  1277. eof(source)
  1278. struct inbuf *source;
  1279. {
  1280.     return(source->eof);
  1281. }
  1282.  
  1283.  
  1284. /* Note that we don't even bother to "open" for output; just use
  1285.  * file descriptor 1 (normally stdout)
  1286.  */
  1287. bufwrite(from,len,outbuf)
  1288. char *from;
  1289. int len;
  1290. struct outbuf *outbuf;
  1291. {
  1292.     if(len <= 0) return;
  1293.     if((len + outbuf->datalen) > OUTBUFSIZE) buf_flush(outbuf);
  1294.     bcopy(from,outbuf->nextp,len);
  1295.     outbuf->datalen += len;
  1296.     outbuf->nextp += len;
  1297.     if((len + outbuf->datalen) >= OUTBUFSIZE) buf_flush(outbuf);
  1298. }
  1299.  
  1300. buf_flush(buf)
  1301. struct outbuf *buf;
  1302. {
  1303.     if(buf->datalen > 0) write(1,buf->buffer,buf->datalen);
  1304.     buf->nextp = buf->buffer;
  1305.     buf->datalen = 0;
  1306. }
  1307. SHAR_EOF
  1308. if test 2781 -ne "`wc -c < 'iobuf.c'`"
  1309. then
  1310.     echo shar: error transmitting "'iobuf.c'" '(should have been 2781 characters)'
  1311. fi
  1312. fi
  1313. echo shar: extracting "'lplot.c'" '(7614 characters)'
  1314. if test -f 'lplot.c'
  1315. then
  1316.     echo shar: will not over-write existing file "'lplot.c'"
  1317. else
  1318. cat << \SHAR_EOF > 'lplot.c'
  1319. /* :set tabstops=4                                                    */
  1320. static char *RCSid = "$Header: lplot.c,v 1.1 86/04/20 16:16:46 sysad Exp $";
  1321.  
  1322. /*
  1323.  * $Log:    lplot.c,v $
  1324.  * Revision 1.1  86/04/20  16:16:46  sysad
  1325.  * Initial distribution version
  1326.  * 
  1327.  * 
  1328.  */
  1329.  
  1330.  
  1331. /* LPLOT and QUICKPLOT -- main program.
  1332.  * This file handles initialization (mostly argument gathering),
  1333.  * calls the plot function to fill the output array, then processes
  1334.  * the array and outputs it.
  1335.  */
  1336.  
  1337. /* It is the intent of the author that this software may be distributed
  1338.  * and used freely, without restriction.  If you make improvements or
  1339.  * enhancements, I would appreciate a copy.
  1340.  *
  1341.  * Duane H. Hesser    Teltone Corporation
  1342.  * ....uw-beaver!tikal!sysad
  1343.  * ....uw-beaver!tikal!dhh
  1344.  */
  1345.  
  1346. #include "extern.h"
  1347. #ifdef DEBUG
  1348. #include <stdio.h>
  1349. #endif
  1350.  
  1351.  
  1352. main(argc,argv)
  1353. int argc;
  1354. char **argv;
  1355. {
  1356.     extern void onintr();
  1357.     extern int read_stream();
  1358.     struct inbuf src;
  1359.     int files = 0;
  1360.     double atof();
  1361. #ifndef QUICKPLOT
  1362.     char *user, *host, *actfile;
  1363. #endif
  1364.  
  1365.     Name = argv[0];
  1366.     ++argv;
  1367. #ifdef DEBUG
  1368.     setbuf(stdout,(char *)0);
  1369. #endif
  1370. #ifndef QUICKPLOT
  1371.     if(strcmp(Name,"rlplot") == 0)
  1372.     {
  1373.         ++Rotate;
  1374.     }
  1375. #endif
  1376.  
  1377.  
  1378.     Eflag = 1;
  1379. #ifdef QUICKPLOT
  1380.     getsize((char *)0);                /* get the size of the terminal */
  1381. #else
  1382.     user = host = actfile = (char *)0;
  1383. #endif
  1384.     while(--argc) 
  1385.     {
  1386.         if(argv[0][0] == '-')
  1387.         {
  1388.             switch(argv[0][1])
  1389.             {
  1390. #ifdef QUICKPLOT
  1391.             case 'T':    /* size for a specific terminal                */
  1392.                 getsize(argv[1]);
  1393.                 --argc;
  1394.                 ++argv;
  1395.                 break;
  1396.             case 'c':    /* select plotting character                */
  1397.                 plotchar = *argv[1];
  1398.                 --argc;
  1399.                 ++argv;
  1400.                 break;
  1401. #endif
  1402.             case 'r':    /* rotate entire plot 90 degrees            */
  1403.                 ++Rotate;
  1404.                 break;
  1405.             case 'W':
  1406.                 maxcol = atoi(argv[1]);
  1407.                 --argc;
  1408.                 ++argv;
  1409.                 break;
  1410.             case 'H':
  1411.                 maxrow = atoi(argv[1]);
  1412.                 --argc;
  1413.                 ++argv;
  1414.                 break;
  1415.             case 'X':    /* move the whole plot horizontally            */
  1416. #ifdef QUICKPLOT
  1417.                 Xmargin = atof(argv[1]);                /* columns    */
  1418. #else
  1419.                 Xmargin = atof(argv[1]) * XPERINCH;        /* inches    */
  1420. #endif
  1421.                 --argc;
  1422.                 ++argv;
  1423.                 break;
  1424.             case 'Y':    /* move the whole plot vertically            */
  1425. #ifdef QUICKPLOT
  1426.                 Ymargin = atof(argv[1]);                /* rows        */
  1427. #else
  1428.                 Ymargin = atof(argv[1]) * YPERINCH;        /* inches    */
  1429. #endif
  1430.                 --argc;
  1431.                 ++argv;
  1432.                 break;
  1433.             case 's':    /* request x, y, or overall scale factors    */
  1434.                 if(argv[0][2] == '\0')
  1435.                     Scalfac = atof(argv[1]);
  1436.                 else if(argv[0][2] == 'x')
  1437.                     argxfac = atof(argv[1]);
  1438.                 else if(argv[0][2] == 'y')
  1439.                     argyfac = atof(argv[1]);
  1440.                 --argc;
  1441.                 ++argv;
  1442.                 break;
  1443.             case 'e':    /* force erase before each file is plotted    */
  1444.                 ++Eflag;
  1445.                 Nflag = 0;
  1446.                 break;
  1447.             case 'N':    /* suppress erasing                            */
  1448.                 ++Nflag;
  1449.                 Eflag = 0;
  1450.                 break;
  1451. #ifndef QUICKPLOT
  1452.             case 'x':    /* get width in pixels (from lpr)            */
  1453.                 maxcol = atoi(&argv[0][2]);
  1454.                 break;
  1455.             case 'y':    /* get hieght in pixels (from lpr)            */
  1456.                 maxrow = atoi(&argv[0][2]);
  1457.                 break;
  1458.             case 'n':    /* get user (from lpr) for accounting        */
  1459.                 user = argv[1];
  1460.                 ++argv;
  1461.                 --argc;
  1462.                 break;
  1463.             case 'h':    /* get host and accounting file (from lpr)    */
  1464.                 host = argv[1];
  1465.                 ++argv; --argc;
  1466.                 actfile = argv[2];
  1467.                 --argc; ++argv;
  1468.                 break;
  1469. #endif
  1470. #ifdef DEBUG
  1471.             case 'd':    /* debug                                    */
  1472.                 debug = atoi(argv[1]);
  1473.                 ++argv;
  1474.                 --argc;
  1475.                 break;
  1476. #endif
  1477.             case '\0':    /* read standard input here                    */
  1478.                 src.fd = 0;
  1479.                 src.nleft = 0;
  1480.                 src.eof = 0;
  1481.                 lplot(&src);
  1482.                 if(Plotdata && Eflag) output();
  1483.                 bufclose(&src);
  1484.                 break;
  1485.             default:
  1486.                 break;
  1487.             }
  1488.         }
  1489.         else        /* file argument                                */
  1490.         {
  1491.             if(bufopen(argv[0],&src) < 0) 
  1492.             {
  1493.                 char ebuf[64];
  1494.                 sprintf(ebuf,"%s: can't open input %s\n",Name,argv[0]);
  1495.                 write(2,ebuf,strlen(ebuf));
  1496.                 exit(1);
  1497.             }
  1498.             lplot(&src);
  1499.             if(Plotdata && Eflag) output();
  1500.             bufclose(&src);
  1501.             files++;
  1502.         }
  1503.         argv++;
  1504.     }
  1505.     Nflag = 0;
  1506.     if(files == 0)    /* no file arguments given; read stdin            */
  1507.     {
  1508.         src.fd = 0;
  1509.         src.nleft = 0;
  1510.         src.eof = 0;
  1511.         lplot(&src);
  1512.     }
  1513.     if(Plotdata) output();    /* force out anything that may be left    */
  1514. #ifndef QUICKPLOT
  1515.     if(actfile && *actfile && (access(actfile,02) == 0))
  1516.     {
  1517.         int fda = open(actfile,1);
  1518.         char abuf[32];
  1519.         if(fda < 0) exit(0);
  1520.         if(!user || !*user) user = "lplot";
  1521.         if(!host || !*host) host = "unknown";
  1522.         sprintf(abuf,"%7.2f\t%s:%s\n", (float)Npages, host, user);
  1523.         write(fda,abuf,strlen(abuf));
  1524.     }
  1525. #endif
  1526.     exit(0);
  1527. }
  1528.  
  1529. lplot(source)
  1530. struct inbuf *source;
  1531. {
  1532.     int got;
  1533.     /* This next is a hack to suppress an initial "erase" command,
  1534.      * (as "graph(1)" is so fond of issuing) before there is anything
  1535.      * to plot.  If there is plot data, the erase will force it out.
  1536.      * After the first page is printed, an erase will be honored
  1537.      * unconditionally (unless erasing is suppressed with '-N').
  1538.      */
  1539.     static int firstplot = 1;
  1540.  
  1541.     while( (got = read_stream(source)))
  1542.     {
  1543. #ifdef DEBUG
  1544.         if(debug & 2) printf("got=%ld,Plotdata=%d\n",got,Plotdata);
  1545. #endif
  1546.         /* got = -1 means no plot cmds except erase                    */
  1547.         if((got == -1) && !Nflag && !Plotdata)
  1548.         {
  1549.             if(!firstplot)
  1550.                 write(1,"\014",1);
  1551.             continue;
  1552.         }
  1553.         Plotdata++;                /* there is something to plot        */
  1554.         firstplot = 0;
  1555.         if(!Nflag && got < 0)    /* erase command received            */
  1556.             output();
  1557.     }
  1558. }
  1559.  
  1560. /* Send the plot data to stdout.  The data are processed by rows,
  1561.  * each of which is treated as a string.  We don't send nulls at
  1562.  * the end of the string, but we must fill in null bytes before
  1563.  * the last byte in the row which contains data.  For lplot, we
  1564.  * must set bit 6 ('\100') to make the byte valid for plotting;
  1565.  * for quickplot, null bytes need to be spaces.
  1566.  */
  1567. output()
  1568. {
  1569.     int y,len,maxc;
  1570.     char c;
  1571.     struct outbuf outbuf;
  1572.  
  1573.     outbuf.datalen = 0;
  1574.     outbuf.nextp = outbuf.buffer;
  1575.  
  1576. #ifdef QUICKPLOT
  1577.     maxc = maxcol;
  1578. #else
  1579.     maxc = (maxcol + 5)/6;
  1580. #endif
  1581. #ifdef DEBUG
  1582.     if(debug & 2) printf("output:maxc=%d\n",maxc);
  1583. #endif
  1584.  
  1585.     for(y = maxrow - 1; y >= 0; --y)
  1586.     {
  1587.         char *row = Row[y];
  1588.         char *end = &row[maxc];
  1589.  
  1590.         /* make sure the string is terminated                         */
  1591.         *end-- = '\0';
  1592.  
  1593.         /* find the last non-null byte in the row                    */
  1594.         while(!*end && (end >= row))    end--;
  1595.         len = end - row + 1;
  1596. #ifdef DEBUG
  1597.         if(debug & 4) printf("row[%d]=%d bytes\n",y,len);
  1598. #endif
  1599.  
  1600. #ifndef QUICKPLOT
  1601.         /* set bit 6 in all bytes to be transmitted                    */
  1602.         while(end >= row) *end-- |= BIT[6]; 
  1603.         Row[y][len++] = GRAPHICSCHAR;
  1604.         Row[y][len++] = '\n';
  1605.         Row[y][len] = '\0';
  1606. #else
  1607.         /* just send a space for quickplot                            */
  1608.         while(end >= row) if(!*end) *end-- = ' '; else --end;
  1609.         len = strlen(Row[y]);
  1610.         /* leave cursor lower right                                    */
  1611.         if(y)
  1612.         {
  1613.             strcat(Row[y],"\n");
  1614.             ++len;
  1615.         }
  1616. #endif
  1617.         bufwrite(Row[y],len,&outbuf);
  1618. #ifdef DEBUG
  1619.         if(debug & 4) buf_flush(&outbuf);
  1620. #endif
  1621.         bzero(Row[y],XARRAYSIZE);    /* clear the array for next plot */
  1622.     }
  1623.     Plotdata = 0;
  1624.     buf_flush(&outbuf);
  1625. #ifdef QUICKPLOT
  1626.     /* Pause after each plot unless output is redirected.
  1627.      * Read from the error channel because we might be reading
  1628.      * plot data from stdin.
  1629.      */
  1630.     if(isatty(1) && isatty(2)) read(2,&c,1);
  1631.     else write(1,"\n",1);
  1632. #else
  1633.     /* for accounting, one page per plot                            */
  1634.     Npages++;
  1635. #endif
  1636. }
  1637.  
  1638. #ifdef QUICKPLOT
  1639. /* get the size of the terminal from the environment                */
  1640. getsize(term)
  1641. char *term;
  1642. {
  1643.     char *terminal,termbuf[1024],*getenv();
  1644.     int cols,lines;
  1645.  
  1646.     /* set defaults                                                    */
  1647.     maxcol = cols = XDOTS;
  1648.     maxrow = lines = YDOTS;
  1649.  
  1650.     if(!term) terminal = getenv("TERM");
  1651.     else terminal = term;
  1652.  
  1653.     if((terminal)  && (tgetent(termbuf,terminal) == 1))
  1654.     {
  1655.         cols = tgetnum("co");
  1656.         if(cols > 0) maxcol = cols;
  1657.         lines = tgetnum("li");
  1658.         if(lines > 0) maxrow = lines;
  1659.         autowrap = tgetflag("am");
  1660.     }
  1661.     spacex = maxcol;
  1662.     spacey = maxrow;
  1663. }
  1664. #endif QUICKPLOT
  1665. SHAR_EOF
  1666. if test 7614 -ne "`wc -c < 'lplot.c'`"
  1667. then
  1668.     echo shar: error transmitting "'lplot.c'" '(should have been 7614 characters)'
  1669. fi
  1670. fi
  1671. echo shar: extracting "'read_stream.c'" '(3320 characters)'
  1672. if test -f 'read_stream.c'
  1673. then
  1674.     echo shar: will not over-write existing file "'read_stream.c'"
  1675. else
  1676. cat << \SHAR_EOF > 'read_stream.c'
  1677. /* :set tabstops=4                                                    */
  1678. static char *RCSid = "$Header: read_stream.c,v 1.1 86/04/20 16:16:49 sysad Exp $";
  1679.  
  1680. /*
  1681.  * $Log:    read_stream.c,v $
  1682.  * Revision 1.1  86/04/20  16:16:49  sysad
  1683.  * Initial distribution version
  1684.  * 
  1685.  * 
  1686.  */
  1687.  
  1688.  
  1689. /* It is the intent of the author that this software may be distributed
  1690.  * and used freely, without restriction.  If you make improvements or
  1691.  * enhancements, I would appreciate a copy.
  1692.  *
  1693.  * Duane H. Hesser    Teltone Corporation
  1694.  * ....uw-beaver!tikal!sysad
  1695.  * ....uw-beaver!tikal!dhh
  1696.  */
  1697.  
  1698. #include "defs.h"
  1699. #include "extern.h"
  1700.  
  1701. read_stream(source)
  1702. struct inbuf *source;
  1703. {
  1704.     char c;
  1705.     char string[256],ebuf[64];
  1706.     int len,got;
  1707.     short x0,y0,x1,y1,r;
  1708.     char getbyte();
  1709.     short getshort();
  1710.  
  1711.     got = 0;
  1712. #ifdef QUICKPLOT
  1713.     linemask = plotchar;
  1714. #endif
  1715.     while((c = getbyte(source)) && !eof(source))
  1716.     {
  1717.         ++got;
  1718.         switch(c)
  1719.         {
  1720.             case 'm':
  1721.                 curx = getshort(source);
  1722.                 cury = getshort(source);
  1723.                 move(curx,cury);
  1724.                 break;
  1725.             
  1726.             case 'n':
  1727.                 curx = getshort(source);
  1728.                 cury = getshort(source);
  1729.                 cont(curx,cury);
  1730.                 break;
  1731.             
  1732.             case 'p':
  1733.                 curx = getshort(source);
  1734.                 cury = getshort(source);
  1735.                 move(curx,cury);
  1736.                 point(curxdot,curydot);
  1737.                 break;
  1738.             
  1739.             case 'l':
  1740.                 x1 = getshort(source);
  1741.                 y1 = getshort(source);
  1742.                 curx = getshort(source);
  1743.                 cury = getshort(source);
  1744.                 line(x1,y1,curx,cury);
  1745.                 break;
  1746.             
  1747.             case 't':
  1748.                 len = getstr(source,string);
  1749.                 label(string,len);
  1750.                 break;
  1751.             
  1752.             case 'a':
  1753.                 curx = getshort(source);
  1754.                 cury = getshort(source);
  1755.                 x0 = getshort(source);
  1756.                 y0 = getshort(source);
  1757.                 x1 = getshort(source);
  1758.                 y1 = getshort(source);
  1759.                 arc(curx,cury,x0,y0,x1,y1);
  1760.                 /* The manual doesn't specify this, but it seems
  1761.                  * the most reasonable thing to do.
  1762.                  */
  1763.                 move(curx,cury);
  1764.                 break;
  1765.             
  1766.             case 'c':
  1767.                 x1 = getshort(source);
  1768.                 y1 = getshort(source);
  1769.                 r = getshort(source);
  1770.                 circle(x1,y1,r);
  1771.                 /* (x1,y1) becomes current point                    */
  1772.                 break;
  1773.             
  1774.             case 'e':
  1775.                 return(-got); /* negative got triggers erase        */
  1776.                 break;
  1777.             break;
  1778.             
  1779.             case 'f':
  1780.                 --got;
  1781.                 len = getstr(source,string);
  1782.                 if(!len) break;
  1783.  
  1784. #ifdef DEBUG
  1785.                 if(debug & 1) printf("linemask=%s",string);
  1786. #endif
  1787. #ifdef QUICKPLOT
  1788.                 if(strcmp(string,"solid") == 0)
  1789.                     linemask = plotchar;
  1790.                 else if(strcmp(string,"dotted") == 0)
  1791.                     linemask = '2';
  1792.                 else if(strcmp(string,"shortdashed") == 0)
  1793.                     linemask = '3';
  1794.                 else if(strcmp(string,"longdashed") == 0)
  1795.                     linemask = '4';
  1796.                 else if(strcmp(string,"dotdashed") == 0)
  1797.                     linemask = '5';
  1798.                 break;
  1799. #else
  1800.                 if(strcmp(string,"solid") == 0)
  1801.                     linemask = SOLID;
  1802.                 else if(strcmp(string,"dotted") == 0)
  1803.                     linemask = DOTTED;
  1804.                 else if(strcmp(string,"shortdashed") == 0)
  1805.                     linemask = SHORTDASHED;
  1806.                 else if(strcmp(string,"longdashed") == 0)
  1807.                     linemask = LONGDASHED;
  1808.                 else if(strcmp(string,"dotdashed") == 0)
  1809.                     linemask = DOTDASHED;
  1810.                 break;
  1811. #endif QUICKPLOT
  1812.             
  1813.             case 's':
  1814.                 --got;
  1815.                 x0 = getshort(source);
  1816.                 y0 = getshort(source);
  1817.                 x1 = getshort(source);
  1818.                 y1 = getshort(source);
  1819.                 space(x0,y0,x1,y1);
  1820.                 break;
  1821.             default:
  1822.                 --got;
  1823.                 sprintf(ebuf,"bad input data: cmd (0%o)\n",c);
  1824.                 write(2,ebuf,strlen(ebuf));
  1825.                 break;
  1826.         }
  1827.     }
  1828.     /* return the number of commands decoded                        */
  1829.     return(--got > 0 ? got : 0);
  1830. }
  1831.  
  1832. SHAR_EOF
  1833. if test 3320 -ne "`wc -c < 'read_stream.c'`"
  1834. then
  1835.     echo shar: error transmitting "'read_stream.c'" '(should have been 3320 characters)'
  1836. fi
  1837. fi
  1838. echo shar: extracting "'defs.h'" '(2516 characters)'
  1839. if test -f 'defs.h'
  1840. then
  1841.     echo shar: will not over-write existing file "'defs.h'"
  1842. else
  1843. cat << \SHAR_EOF > 'defs.h'
  1844. /* :set tabstop=4                                                    */
  1845. /*
  1846.  * $Header: defs.h,v 1.1 86/04/20 16:16:52 sysad Exp $
  1847.  */
  1848.  
  1849. /*
  1850.  * $Log:    defs.h,v $
  1851.  * Revision 1.1  86/04/20  16:16:52  sysad
  1852.  * Initial distribution version
  1853.  * 
  1854.  * 
  1855.  */
  1856.  
  1857.  
  1858. /* It is the intent of the author that this software may be distributed
  1859.  * and used freely, without restriction.  If you make improvements or
  1860.  * enhancements, I would appreciate a copy.
  1861.  *
  1862.  * Duane H. Hesser    Teltone Corporation
  1863.  * ....uw-beaver!tikal!sysad
  1864.  * ....uw-beaver!tikal!dhh
  1865.  */
  1866.  
  1867. #ifndef QUICKPLOT
  1868. #define    GRAPHICSCHAR    '\005'    /* puts printer in graphics mode    */
  1869. #define    XPERINCH    ((double)60.0)        /* horizontal dot density    */
  1870. #define    YPERINCH    ((double)72.0)        /* vertical dot density        */
  1871. #define    SPACEX    ((8 * XPERINCH) - 1)    /* dots for 8 inch plot area*/
  1872. #define    SPACEY    ((8 * YPERINCH)    - 1)    /* dots for 8 inch plot area*/
  1873. #define    XDOTS    792                /* maximum possible horizontal dots    */
  1874. /* we lose 12 dots vertically with the print head positioned for
  1875.  * printing on the first line in ascii mode
  1876.  */
  1877. #define    YDOTS    780                /* maximum possible vertical dots    */
  1878. #define    XBYTES    (XDOTS/6)        /* bytes needed for XDOTS            */
  1879. #define    MAXX    (XDOTS - 1)        /* maximum plottable x value        */
  1880. #define    MAXY    (YDOTS - 1)        /* maximum plottable y value        */
  1881. #else
  1882. #define    PLOTCHAR    'X'            /* use this char for plotting        */
  1883. #define    XPERINCH    ((double)10.0)        /* horizontal dot density    */
  1884. #define    YPERINCH    ((double)6.0)        /* vertical dot density        */
  1885. #define    SPACEX    ((8 * XPERINCH) - 1)    /* dots for 8 inch plot area*/
  1886. #define    SPACEY    ((8 * YPERINCH)    - 1)    /* dots for 8 inch plot area*/
  1887. #define    XDOTS    132                /* maximum possible horizontal dots    */
  1888. #define    YDOTS    66                /* maximum possible vertical dots    */
  1889. #define    XBYTES    (XDOTS)            /* horizontal dimension of array    */
  1890. #define    MAXX    (XDOTS - 1)        /* maximum plottable x value        */
  1891. #define    MAXY    (YDOTS - 1)        /* maximum plottable y value        */
  1892. #endif
  1893.  
  1894. /* Horizontal dimension of Row array.
  1895.  * Add 1 byte for a null, 1 for LF, 1 for graphics byte
  1896.  */
  1897. #define    XARRAYSIZE    (XBYTES + 3)
  1898.  
  1899. /* Linemode masks; used in make_line() for lplot                    */
  1900. #define    SOLID 0177777
  1901. #define    DOTTED 001
  1902. #define    SHORTDASHED 003
  1903. #define    DOTDASHED 013
  1904. #define    LONGDASHED 007
  1905.  
  1906. #ifndef QUICKPLOT
  1907. #define    mapx(x)    ((((double)x - lowx_space) * mapxfac) + Xmargin + 0.5)
  1908. #define    mapy(y)    ((((double)y - lowy_space) * mapyfac) + Ymargin + 0.5)
  1909. #define    plotbit(x,a)    (x & (1 << a))
  1910. #else
  1911. #define    mapx(x)    ((((double)x - lowx_space) * mapxfac) + Xmargin + 0.01)
  1912. #define    mapy(y)    ((((double)y - lowy_space) * mapyfac) + Ymargin + 0.01)
  1913. #endif
  1914. SHAR_EOF
  1915. if test 2516 -ne "`wc -c < 'defs.h'`"
  1916. then
  1917.     echo shar: error transmitting "'defs.h'" '(should have been 2516 characters)'
  1918. fi
  1919. fi
  1920. echo shar: extracting "'extern.h'" '(1193 characters)'
  1921. if test -f 'extern.h'
  1922. then
  1923.     echo shar: will not over-write existing file "'extern.h'"
  1924. else
  1925. cat << \SHAR_EOF > 'extern.h'
  1926. /* :set tabstop=4                                                    */
  1927. /*
  1928.  * $Header: extern.h,v 1.1 86/04/20 16:17:03 sysad Exp $
  1929.  */
  1930.  
  1931. /*
  1932.  * $Log:    extern.h,v $
  1933.  * Revision 1.1  86/04/20  16:17:03  sysad
  1934.  * Initial distribution version
  1935.  * 
  1936.  * 
  1937.  */
  1938.  
  1939.  
  1940. /* It is the intent of the author that this software may be distributed
  1941.  * and used freely, without restriction.  If you make improvements or
  1942.  * enhancements, I would appreciate a copy.
  1943.  *
  1944.  * Duane H. Hesser    Teltone Corporation
  1945.  * ....uw-beaver!tikal!sysad
  1946.  * ....uw-beaver!tikal!dhh
  1947.  */
  1948.  
  1949. #include "defs.h"
  1950. #include "io.h"
  1951. extern char Row[][XARRAYSIZE];
  1952. #ifndef QUICKPLOT
  1953. extern char BIT[];
  1954. #else
  1955. extern char plotchar;
  1956. extern int autowrap;
  1957. #endif
  1958.  
  1959. extern double spacex,spacey;
  1960. extern double xspace,yspace;
  1961. extern double lowx_space,highx_space,lowy_space,highy_space;
  1962. extern int maxx,maxy,maxrow,maxcol;
  1963.  
  1964. extern short curx,cury,curxdot,curydot;
  1965. extern double Scalfac,xfac,yfac,argxfac,argyfac;
  1966. extern double mapxfac,mapyfac;
  1967. extern double Xmargin,Ymargin;
  1968.  
  1969. extern int Plotdata;
  1970. extern int Eflag;
  1971. extern int Nflag;
  1972. extern int linemask;
  1973.  
  1974. extern char *Name;
  1975. #ifdef DEBUG
  1976. extern int debug;
  1977. #endif
  1978. extern int Rotate;
  1979.  
  1980. #ifndef QUICKPLOT
  1981. extern int Npages;
  1982. extern char table[][10];
  1983. #endif
  1984. SHAR_EOF
  1985. if test 1193 -ne "`wc -c < 'extern.h'`"
  1986. then
  1987.     echo shar: error transmitting "'extern.h'" '(should have been 1193 characters)'
  1988. fi
  1989. fi
  1990. echo shar: extracting "'io.h'" '(701 characters)'
  1991. if test -f 'io.h'
  1992. then
  1993.     echo shar: will not over-write existing file "'io.h'"
  1994. else
  1995. cat << \SHAR_EOF > 'io.h'
  1996. /* :set tabstop=4                                                    */
  1997. /*
  1998.  * $Header: io.h,v 1.1 86/04/20 16:17:06 sysad Exp $
  1999.  */
  2000.  
  2001. /*
  2002.  * $Log:    io.h,v $
  2003.  * Revision 1.1  86/04/20  16:17:06  sysad
  2004.  * Initial distribution version
  2005.  * 
  2006.  * 
  2007.  */
  2008.  
  2009.  
  2010. /* It is the intent of the author that this software may be distributed
  2011.  * and used freely, without restriction.  If you make improvements or
  2012.  * enhancements, I would appreciate a copy.
  2013.  *
  2014.  * Duane H. Hesser    Teltone Corporation
  2015.  * ....uw-beaver!tikal!sysad
  2016.  * ....uw-beaver!tikal!dhh
  2017.  */
  2018.  
  2019. #define    INBUFSIZE    2048
  2020. #define    OUTBUFSIZE    2048
  2021.  
  2022. struct inbuf
  2023. {
  2024.     int fd;
  2025.     int nleft;
  2026.     int eof;
  2027.     char *nextp;
  2028.     char buff[INBUFSIZE];
  2029. };
  2030.  
  2031. struct outbuf {
  2032.     int datalen;
  2033.     char *nextp;
  2034.     char buffer[OUTBUFSIZE];
  2035. };
  2036. SHAR_EOF
  2037. if test 701 -ne "`wc -c < 'io.h'`"
  2038. then
  2039.     echo shar: error transmitting "'io.h'" '(should have been 701 characters)'
  2040. fi
  2041. fi
  2042. if test ! -d 'testprogs.d'
  2043. then
  2044.     echo shar: creating directory "'testprogs.d'"
  2045.     mkdir 'testprogs.d'
  2046. fi
  2047. echo shar: extracting "'testprogs.d/Makefile'" '(497 characters)'
  2048. if test -f 'testprogs.d/Makefile'
  2049. then
  2050.     echo shar: will not over-write existing file "'testprogs.d/Makefile'"
  2051. else
  2052. cat << \SHAR_EOF > 'testprogs.d/Makefile'
  2053. all:    box circle lineh linev lined dlined arc
  2054.  
  2055. arc:    arc.c
  2056.     cc -o arc arc.c -lplot -lm
  2057.  
  2058. box:    box.c
  2059.     cc -o box box.c -lplot
  2060.  
  2061. circle:    circle.c
  2062.     cc -o circle circle.c -lplot -lm
  2063.  
  2064. lineh:    lineh.c
  2065.     cc -o lineh lineh.c -lplot
  2066.  
  2067. linev:    linev.c
  2068.     cc -o linev linev.c -lplot
  2069.  
  2070. lined:    lined.c
  2071.     cc -o lined lined.c -lplot
  2072.  
  2073. dlined:    dlined.c
  2074.     cc -o dlined dlined.c -lplot
  2075.  
  2076. graphplot:
  2077.     grplot
  2078.     @echo 'type "quickplot tmpload" or "lplot tmpload | lpr -v"'
  2079. clean:
  2080.     rm -f box circle lineh linev lined tmpload dlined arc
  2081. SHAR_EOF
  2082. if test 497 -ne "`wc -c < 'testprogs.d/Makefile'`"
  2083. then
  2084.     echo shar: error transmitting "'testprogs.d/Makefile'" '(should have been 497 characters)'
  2085. fi
  2086. fi
  2087. echo shar: extracting "'testprogs.d/lined.c'" '(270 characters)'
  2088. if test -f 'testprogs.d/lined.c'
  2089. then
  2090.     echo shar: will not over-write existing file "'testprogs.d/lined.c'"
  2091. else
  2092. cat << \SHAR_EOF > 'testprogs.d/lined.c'
  2093. /* diagaonal line lower left to upper right */
  2094. main(argc,argv)
  2095. int argc;
  2096. char **argv;
  2097. {
  2098.     int x0,x1,y0,y1;
  2099.  
  2100.     x0 = 0;
  2101.     y0 = 0;
  2102.     x1 = 2000;
  2103.     y1 = 2000;
  2104.     space(x0,y0,2000,2000);
  2105.     move(x0,y0);
  2106.     label("+");
  2107.     move(x1,y1);
  2108.     label("+");
  2109.     line(x0,y0,x1,y1);
  2110.     erase();
  2111.     exit(0);
  2112. }
  2113. SHAR_EOF
  2114. if test 270 -ne "`wc -c < 'testprogs.d/lined.c'`"
  2115. then
  2116.     echo shar: error transmitting "'testprogs.d/lined.c'" '(should have been 270 characters)'
  2117. fi
  2118. fi
  2119. echo shar: extracting "'testprogs.d/linev.c'" '(273 characters)'
  2120. if test -f 'testprogs.d/linev.c'
  2121. then
  2122.     echo shar: will not over-write existing file "'testprogs.d/linev.c'"
  2123. else
  2124. cat << \SHAR_EOF > 'testprogs.d/linev.c'
  2125. /* vertical line along left side of plot space */
  2126. main(argc,argv)
  2127. int argc;
  2128. char **argv;
  2129. {
  2130.     int x0,x1,y0,y1;
  2131.  
  2132.     x0 = 0;
  2133.     y0 = 0;
  2134.     x1 = 2000;
  2135.     y1 = 2000;
  2136.     space(x0,y0,2000,2000);
  2137.     move(x0,y0);
  2138.     label("+");
  2139.     move(x0,y1);
  2140.     label("+");
  2141.     line(x0,y0,x0,y1);
  2142.     erase();
  2143.     exit(0);
  2144. }
  2145. SHAR_EOF
  2146. if test 273 -ne "`wc -c < 'testprogs.d/linev.c'`"
  2147. then
  2148.     echo shar: error transmitting "'testprogs.d/linev.c'" '(should have been 273 characters)'
  2149. fi
  2150. fi
  2151. echo shar: extracting "'testprogs.d/box.c'" '(373 characters)'
  2152. if test -f 'testprogs.d/box.c'
  2153. then
  2154.     echo shar: will not over-write existing file "'testprogs.d/box.c'"
  2155. else
  2156. cat << \SHAR_EOF > 'testprogs.d/box.c'
  2157. /* box surrounding plot space--no args */
  2158.  
  2159. main(argc,argv)
  2160. int argc;
  2161. char **argv;
  2162. {
  2163.     int x0,x1,y0,y1;
  2164.  
  2165.     x0 = 0;
  2166.     y0 = 0;
  2167.     x1 = 2000;
  2168.     y1 = 2000;
  2169.     space(x0,y0,x1,y1);
  2170.  
  2171.     move(x0,y0);
  2172.     label("1");
  2173.     move(x0,y1);
  2174.     label("2");
  2175.     move(x1,y1);
  2176.     label("3");
  2177.     move(x1,y0);
  2178.     label("4");
  2179.     move(x0,y0);
  2180.     line(x0,y0,x0,y1);
  2181.     cont(x1,y1);
  2182.     cont(x1,y0);
  2183.     cont(x0,y0);
  2184.     erase();
  2185.     exit(0);
  2186. }
  2187. SHAR_EOF
  2188. if test 373 -ne "`wc -c < 'testprogs.d/box.c'`"
  2189. then
  2190.     echo shar: error transmitting "'testprogs.d/box.c'" '(should have been 373 characters)'
  2191. fi
  2192. fi
  2193. echo shar: extracting "'testprogs.d/dlined.c'" '(475 characters)'
  2194. if test -f 'testprogs.d/dlined.c'
  2195. then
  2196.     echo shar: will not over-write existing file "'testprogs.d/dlined.c'"
  2197. else
  2198. cat << \SHAR_EOF > 'testprogs.d/dlined.c'
  2199. /* with no args, gives dotted diagaonal line. one optional argument is
  2200.  * permitted to change line mode.  permitted modes are:
  2201.  *    solid
  2202.  *    dotted
  2203.  *  shortdashed
  2204.  *  longdashed
  2205.  *  dotdashed
  2206.  */
  2207. main(argc,argv)
  2208. int argc;
  2209. char **argv;
  2210. {
  2211.     int x0,x1,y0,y1;
  2212.  
  2213.     x0 = 0;
  2214.     y0 = 0;
  2215.     x1 = 2000;
  2216.     y1 = 2000;
  2217.     space(x0,y0,2000,2000);
  2218.     if(argc > 1) linemod(argv[1]);
  2219.     else linemod("dotted");
  2220.     move(x0,y0);
  2221.     label("+");
  2222.     move(x1,y1);
  2223.     label("+");
  2224.     line(x0,y0,x1,y1);
  2225.     erase();
  2226.     exit(0);
  2227. }
  2228. SHAR_EOF
  2229. if test 475 -ne "`wc -c < 'testprogs.d/dlined.c'`"
  2230. then
  2231.     echo shar: error transmitting "'testprogs.d/dlined.c'" '(should have been 475 characters)'
  2232. fi
  2233. fi
  2234. echo shar: extracting "'testprogs.d/lineh.c'" '(273 characters)'
  2235. if test -f 'testprogs.d/lineh.c'
  2236. then
  2237.     echo shar: will not over-write existing file "'testprogs.d/lineh.c'"
  2238. else
  2239. cat << \SHAR_EOF > 'testprogs.d/lineh.c'
  2240. /* hoizontal line across bottom of plot space */
  2241.  
  2242. main(argc,argv)
  2243. int argc;
  2244. char **argv;
  2245. {
  2246.     int x0,x1,y0,y1;
  2247.  
  2248.     x0 = 0;
  2249.     y0 = 0;
  2250.     x1 = 2000;
  2251.     y1 = 2000;
  2252.     space(x0,y0,2000,2000);
  2253.     move(x0,y0);
  2254.     label("+");
  2255.     move(x1,y0);
  2256.     label("+");
  2257.     line(x0,y0,x1,y0);
  2258.     erase();
  2259.     exit(0);
  2260. }
  2261. SHAR_EOF
  2262. if test 273 -ne "`wc -c < 'testprogs.d/lineh.c'`"
  2263. then
  2264.     echo shar: error transmitting "'testprogs.d/lineh.c'" '(should have been 273 characters)'
  2265. fi
  2266. fi
  2267. echo shar: extracting "'testprogs.d/arc.c'" '(541 characters)'
  2268. if test -f 'testprogs.d/arc.c'
  2269. then
  2270.     echo shar: will not over-write existing file "'testprogs.d/arc.c'"
  2271. else
  2272. cat << \SHAR_EOF > 'testprogs.d/arc.c'
  2273. /* arc centered on x,y starting at x0,y0, thru x1,y1    */
  2274.  
  2275. #include <math.h>
  2276. main(argc,argv)
  2277. int argc;
  2278. char **argv;
  2279. {
  2280.     int x,y,x0,y0,x1,y1;
  2281.  
  2282.     if(argc == 1)
  2283.     {
  2284.         x = 1000;
  2285.         y = 1000;
  2286.         x0 = 2000;
  2287.         y0 = 1000;
  2288.         x1 = 700;
  2289.         y1 = 700;
  2290.     }
  2291.     else if(argc != 7)
  2292.     {
  2293.         printf("usage: arc x y x0 y0 x1 y1\n\t(range 0-2000)\n");
  2294.         exit(1);
  2295.     }
  2296.     else
  2297.     {
  2298.         x = atoi(argv[1]);
  2299.         y = atoi(argv[2]);
  2300.         x0 = atoi(argv[3]);
  2301.         y0 = atoi(argv[4]);
  2302.         x1 = atoi(argv[5]);
  2303.         y1 = atoi(argv[6]);
  2304.     }
  2305.     space(0,0,2000,2000);
  2306.     arc(x,y,x0,y0,x1,y1);
  2307.     erase();
  2308.     exit(0);
  2309. }
  2310. SHAR_EOF
  2311. if test 541 -ne "`wc -c < 'testprogs.d/arc.c'`"
  2312. then
  2313.     echo shar: error transmitting "'testprogs.d/arc.c'" '(should have been 541 characters)'
  2314. fi
  2315. fi
  2316. echo shar: extracting "'testprogs.d/circle.c'" '(213 characters)'
  2317. if test -f 'testprogs.d/circle.c'
  2318. then
  2319.     echo shar: will not over-write existing file "'testprogs.d/circle.c'"
  2320. else
  2321. cat << \SHAR_EOF > 'testprogs.d/circle.c'
  2322. /* circle inscribed on plot space--no args */
  2323. #include <math.h>
  2324. main(argc,argv)
  2325. int argc;
  2326. char **argv;
  2327. {
  2328.     int x,y,r;
  2329.  
  2330.     x = 1000;
  2331.     y = 1000;
  2332.     r = 1000;
  2333.     space(0,0,2000,2000);
  2334.     circle(x,y,r);
  2335.     erase();
  2336.     exit(0);
  2337. }
  2338.  
  2339. SHAR_EOF
  2340. if test 213 -ne "`wc -c < 'testprogs.d/circle.c'`"
  2341. then
  2342.     echo shar: error transmitting "'testprogs.d/circle.c'" '(should have been 213 characters)'
  2343. fi
  2344. fi
  2345. echo shar: done with directory "'testprogs.d'"
  2346. exit 0
  2347. #    End of shell archive
  2348.